import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  // 配置别名
  resolve: {
    alias: {
      "@": path.resolve(__dirname, './src')
    }
  },
  server: {
    // 解决跨域
    proxy: {
      '/api': {
        //目标地址
        target: 'http://127.0.0.1:7001',
        // 允许跨域
        changeOrigin: true,
        // 地址重写
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/apk': {
        //目标地址
        target: 'http://127.0.0.1:3008',
        // 允许跨域
        changeOrigin: true,
        // 地址重写
        rewrite: (path) => path.replace(/^\/apk/, '')
      },
    }
  }
})
